package indv.cfeng.fianceCampus.common.exception;

import indv.cfeng.fianceCampus.common.result.Resp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author Cfeng
 * @date 2022/10/15
 *
 * 公共依赖全局统一异常处理
 */

@Slf4j
@RestControllerAdvice
public class UnifiedExceptionHandler {

    //捕获未定义异常
    @ExceptionHandler(value = Exception.class)
    public Resp handleException(Exception exception) {
        log.error(exception.getMessage(), exception);
        return Resp.failed();
    }
}
